package main.java.easy;

import java.util.Arrays;

/**
 * @Author: 郑国荣
 * @Date: 2023-07-24-11:57
 * @Description:
 */
public class MergeArray {
    public static void merge(int[] nums1,int m,int[] nums2,int n){
        int i=m-1,j=n-1,index=nums1.length-1;
        while (index>=0  && j>=0){
            if (i>=0 && nums1[i]>nums2[j]) {
                nums1[index] = nums1[i];
                i--;
            }
            else{
                nums1[index]=nums2[j];
                j--;
            }
            index--;
        }
    }

    public static void main(String[] args) {
        int[] nums1 = {0};
        int[] nums2 = {1};
        int m = 0;
        int n = nums2.length;
        merge(nums1,m,nums2,n);
        System.out.println(Arrays.toString(nums1));
    }
}
